<%@ page import="cn.ekgc.web166.dao.StudentDao" %>
<%@ page import="cn.ekgc.web166.dao.StudentDaoImpl" %>
<%@ page import="cn.ekgc.web166.entity.Student" %>
<%@ page import="cn.ekgc.web166.entity.Pagination" %><%--
  Created by IntelliJ IDEA.
  User: seal
  Date: 2019/6/12
  Time: 17:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        tr:nth-of-type(odd){
            background: bisque;
        }
    </style>
</head>
<body>
<a href="addStudent.jsp">添加学员</a> | <a href="listStudent.jsp">查看学员</a>
<form action="dolistStudent.jsp" method="post">
    选择每页容量：<select name="pageSize">
        <option value="3">3</option>
        <option value="5">5</option>
        <option value="10">10</option>
    </select>
    <input type="text" placeholder="名字" name="likeName">
    <select name="gender">
        <option value="-1">全部</option>
        <option value="男">男</option>
        <option value="女">女</option>
    </select>
    <input type="date" name="start">(2000-01-01)~<input type="date" name="end">
    <input type="submit" value="查询">
</form>
<table>
    <tr>
        <th>ID</th>
        <th>NAME</th>
        <th>GENDER</th>
        <th>BORNDAY</th>
        <th>操作</th>
    </tr>
    <%
        Pagination<Student> pagination = (Pagination<Student>) request.getAttribute("pagination");
        /*StudentDao dao = new StudentDaoImpl();
        //Pagination<Student> pagination = (Pagination<Student>) request.getAttribute("pagination");
        Pagination<Student> pagination = new Pagination<>();

       //当前页
        String currentPageIndexStr = request.getParameter("currentPageIndex");
        int currentPageIndex = 1;
        if(currentPageIndexStr!=null){
            currentPageIndex=Integer.parseInt(currentPageIndexStr);
        }
        pagination.setCurrentPageIndex(currentPageIndex);
        //每页容量
        pagination.setPageSize(3);
        dao.listByPagination(pagination);*/

//        int count = 0;
        for(Student student:pagination.getResult()){


//        for(Student student:dao.list()){
    %>
    <tr >
        <td><%=student.getId()%></td>
        <td><%=student.getName()%></td>
        <td><%=student.getGender()%></td>
        <td><%=student.getBornday()%></td>
        <td><a href="updateStudent.jsp?id=<%=student.getId()%>">修改</a> | <a href="dodeleteStudent.jsp?id=<%=student.getId()%>">删除</a> </td>
    </tr>

    <%
          //  count++;
        }
    %>
</table>

<%
    if(!pagination.isFirstPage()){
%>
<a href="listStudent.jsp?currentPageIndex=1">首页</a>
<a href="listStudent.jsp?currentPageIndex=<%=pagination.getCurrentPageIndex()-1%>">上一页</a>
<%
    }
%>
<% if(!pagination.isLastPage()){
%>
<a href="listStudent.jsp?currentPageIndex=<%=pagination.getCurrentPageIndex()+1%>">下一页</a>
<a href="listStudent.jsp?currentPageIndex=<%=pagination.getTotalPageCount()%>">尾页</a>
<%
    }
%>
当前是第<%=pagination.getCurrentPageIndex()%>页，共有<%=pagination.getTotalPageCount()%>,共有<%=pagination.getTotalCount()%>条，当前显示第<%=pagination.getFirstRecordNo()%>~<%=pagination.getLastRecordNo()%>条,go<input type="text">页

</body>
</html>
